/*
 * trace_LoopStackInfo.c
 *
 *  Created on: 2012/08/07
 *      Author: guanxiaoying
 */

#include "../table.h"
#include "../trace_cmd_table.h"
typedef struct _LOOPSTACKINFO
{
	AST			astLoop;
	AST			astLoopExitStkBottom;
	AST			astPathStkBottom;
	UCHAR       loopFlg;
}LOOPSTACKINFO, *PLOOPSTACKINFO;

#define TableSize  (sizeof(LOOPSTACKINFO ))
#define TableType  PLOOPSTACKINFO
#define stTable stLoopStackInfoManager.memoryBlocks
#define maxTable stLoopStackInfoManager.maxRecordNum
#define  maxNumPerBlk  (stLoopStackInfoManager.astMaxNum_Block)


static TABLEMANAGER stLoopStackInfoManager = {
//		U4                  usIdx;
		0,
//		PSZ				    con_pszName;    constant
		__FILE__,
//		U2					con_usSize;		constant
		TableSize,
//		U2					block_num;	　　　　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_Block;     １回設定のみ
		0,
//		S4					astTabNum_LastPage; 　　　　Reset clear  際　要
		0,
//		S4					astMaxNum_LastPage;     Reset clear  際　要
		0,
//		U4					ulMaxByte;	　　　　　　　　　　クリアしない
		0,
//		U4					con_minPageSize;　　　　　　　　　　constant
		0
};
static VOID resetListener( U4  procid, U2 index )
{
	if( procid == stLoopStackInfoManager.u4Idx )
	{
		if( index > 0 && index < MAX_VOLUMN_OF_TABLE )
		{
			stTable[ index-1] = NULL;
		}
	}
}
static TableType core_getTable( AST index )
{
	TableType temp = (TableType)Check_Com( &stLoopStackInfoManager, resetListener,  index );
	if( temp != NULL ){ return &temp[index%maxNumPerBlk]; } return NULL;
}
static BOOL ClearTable( VOID )
{
	return Clear_Com( &stLoopStackInfoManager );
}
static BOOL AllocTable( AST astReqArg )
{
	return AllocTable_Com( &stLoopStackInfoManager, astReqArg, resetListener );
}
static AST getMaxLineNum( VOID ){
	return maxTable;
}

static AST getLoop( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLoop;
}
static AST setLoop( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLoop=value;
}
static AST getLoopExitStkBottom( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLoopExitStkBottom;
}
static AST setLoopExitStkBottom( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astLoopExitStkBottom=value;
}
static AST getPathStkBottom( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathStkBottom;
}
static AST setPathStkBottom( AST astIndex, AST value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->astPathStkBottom=value;
}
static U2 getLoopFlg( AST astIndex ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->loopFlg;
}
static U2 setLoopFlg( AST astIndex, U2 value ){
	TableType pTbl = core_getTable( astIndex );
	if( pTbl == NULL )
	{
		return 0;
	}
	return pTbl->loopFlg=value;
}
const TRLOOPSTACKINFOACCESS stTrLoopStkAccess ={
		ClearTable,
		AllocTable,
		getMaxLineNum,
		{
				getLoop,
				setLoop
		},
		{
				getLoopExitStkBottom,
				setLoopExitStkBottom
		},
		{
				getPathStkBottom,
				setPathStkBottom
		},
		{
				getLoopFlg,
				setLoopFlg
		}
};




